package com.example.jetpacktaobao.domain

import com.rcl.mvvmdemo.api.ApiException

data class WanResultData<T>(val data: T, val errorCode: Int, val errorMsg: String) {
    companion object {
        const val SOURCES_CODE = 0
    }

    //如果是成功的code，我们就返回数据，否则就抛出异常
    fun apiData(): T {
        if (errorCode == SOURCES_CODE) {
            return data
        } else {
            throw ApiException(errorCode, errorMsg)
        }
    }
}
